
var pointindex,sitetype
var num=0;
var qingjie,i
Page({

  /**
   * 页面的初始数据
   */
  data: {
    width: wx.getSystemInfoSync().windowWidth,
    height: wx.getSystemInfoSync().windowHeight,
    muban: 4, //0是怪兽 1是模板  2是答题  3是华容道
    num:num,
    num1: 1,
    dengji: 'LV1',
    life: 100,
    gongji: 20,
    fangyu: 20,
    nandu: 1, //难度是1是简单 2是中等 3是困难
    zuoyong:false,
  arr: [{
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第一章《曹兵追击》',
      content: '曹操的铁骑兵已经追上来了，铁骑兵冲散了刘备的军队.',
      renwu: '请与曹兵对决',
      id: 1
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第二章《路遇简雍》',
      content: '看到简雍受伤卧在草中.',
      renwu: '完成答题，获得线索',
      id: 2
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第三章《寻找甘夫人》',
      content: '找到甘夫人，甘夫人与糜夫人被敌军冲散，也不知糜夫人和阿斗的下落。',
      renwu: '完成答题，获得线索',
      id: 3
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第四章《解救糜竺》',
      content: ' 前方有支敌军，糜竺被淳于导绑在马上。',
      renwu: '击杀淳于导，解救糜竺。',
      id: 4
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第五章《青釭剑》',
      content: '有一敌将手提铁枪、身背宝剑奔来，这个人是曹操的背剑将军夏侯恩，背上背的是青釭剑，这把剑锋利无比，削铁如泥。',
      renwu: '完成华容道挑战',
      id: 5
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第六章《寻找糜夫人》',
      content: '找到糜夫人，糜夫人伤了腿，抱着阿斗坐在墙后井边哭',
      renwu: '完成答题获得线索',
      id: 6
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '第七章《枪挑晏明，力战张颌》',
      content: '遇到敌将晏明，张颌。',
      renwu: '击杀二人',
      id: 7
    },
    {
      img: 'https://www.juquduo.com/static/resourse/utils/moban.png',
      show: true,
      title: '终章《力保后主，杀出重围》',
      content: '遇到曹军四将挡住去路。',
      renwu: '完成华容道挑战',
      id: 8
    },

  ],
  content: {},
  },

  onLoad: function (options) {
      var that=this;
      i=options.i
      console.log(options.pointindex)
      pointindex=options.pointindex
      console.log(pointindex,num)//10
      sitetype=options.sitetype
      for (var i = 0; i < that.data.arr.length; i++) {
        if (pointindex == 1) {
          if (that.data.arr[i].id == 1) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie,
            })
          }
        }
        if (pointindex == 4) {
          if (that.data.arr[i].id == 4) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie,
            })
          }
        }
        if (pointindex == 7) {
          if (that.data.arr[i].id == 7) {
            qingjie = that.data.arr[i]
            // that.data.arr.splice(i, 1)
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie,
            })
          }
        }
        if (pointindex == 2) { //第二关
          if (that.data.arr[i].id == 2) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            // that.data.arr.splice(0, i)
            that.setData({
              content: qingjie
            })
          }
        }
        if (pointindex == 3) {
          if (that.data.arr[i].id == 3) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie
            })
          }
        }
        if (pointindex == 6) {
          if (that.data.arr[i].id == 6) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie
            })
          }
        }
        if (pointindex == 5) {
          if (that.data.arr[i].id == 5) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie
            })
          }
        }
        if (pointindex == 8) {
          if (that.data.arr[i].id == 8) {
            qingjie = that.data.arr[i]
            that.data.arr.splice(i, 1)
            that.setData({
              content: qingjie
            })
          }
        }
      }
  },
    //点击情节
    next() {
      var that = this;
      // console.log(num)
      if(pointindex==1){
          that.setData({
            content: that.data.two[1]
        })
      }
      // if(pointindex>=2){
      // if (num > 1) {
      //   for (var i = 0; i < that.data.arr.length; i++) {
      //     if (pointindex == 1) {
      //       if (that.data.arr[i].id == 1) {
      //         qingjie = that.data.arr[i]
              
      //         that.setData({
      //           content: qingjie,
      //         })
      //       }
      //     }
      //     if (pointindex == 4) {
      //       if (that.data.arr[i].id == 4) {
      //         qingjie = that.data.arr[i]
      //         that.data.arr.splice(i, 1)
      //         that.setData({
      //           content: qingjie,
      //         })
      //       }
      //     }
      //     if (pointindex == 7) {
      //       if (that.data.arr[i].id == 7) {
      //         qingjie = that.data.arr[i]
      //         // that.data.arr.splice(i, 1)
      //         that.setData({
      //           content: qingjie,
      //         })
      //       }
      //     }
      //     if (pointindex == 2) { //第二关
      //       if (that.data.arr[i].id == 2) {
              
      //         qingjie = that.data.arr[i]
      //         // that.data.arr.splice(0, i)
      //         that.setData({
      //           content: qingjie
      //         })
      //       }
      //     }
      //     if (pointindex == 3) {
      //       if (that.data.arr[i].id == 3) {
      //         qingjie = that.data.arr[i]
      //         that.data.arr.splice(i, 1)
      //         that.setData({
      //           content: qingjie
      //         })
      //       }
      //     }
      //     if (pointindex == 6) {
      //       if (that.data.arr[i].id == 6) {
      //         qingjie = that.data.arr[i]
      //         that.data.arr.splice(i, 1)
      //         that.setData({
      //           content: qingjie
      //         })
      //       }
      //     }
      //     if (pointindex == 5) {
      //       if (that.data.arr[i].id == 5) {
      //         qingjie = that.data.arr[i]
      //         that.data.arr.splice(i, 1)
      //         that.setData({
      //           content: qingjie
      //         })
      //       }
      //     }
      //     if (pointindex == 8) {
      //       if (that.data.arr[i].id == 8) {
      //         qingjie = that.data.arr[i]
      //         that.data.arr.splice(i, 1)
      //         that.setData({
      //           content: qingjie
      //         })
      //       }
      //     }
      //   }
      // }
    // }
    },
    //点击跳转到怪兽的页面
    tiaozhan() {
      var that = this;
      wx.redirectTo({
        url: '../dgame2/dgame2?pid=' + pointindex + '&sitetype=' + sitetype + '&nandu=' + that.data.nandu,
      })
      that.setData({
        muban: 5,
        content:{}
      })
    },
    //点击跳转到华容道的页面
    tiaozhan2() {
      var that = this;
      wx.redirectTo({
        url: '../hrd/index?pid=' + pointindex + '&sitetype=' + sitetype + '&nandu=' + that.data.nandu,
      })
      that.setData({
        // muban: 5,
        content:{}
      })
    },
    //点击跳转到答题的页面
    tiaozhan1() {
      var that = this;
      wx.redirectTo({
        url: '../dgame2/dgame2?pid=' + pointindex + '&sitetype=' + sitetype + '&nandu=' + that.data.nandu,
      })
      that.setData({
        // muban: 5,
        content:{}
      })
    },
    //点击跳到宝箱的页面
    tiaozhan3(){
      console.log(2)
    },
    //点击进入选择难易程度
    next1() {
      var that = this;
      if (pointindex == 4 || pointindex == 1 || pointindex == 7) {
        that.setData({
          muban: 0
        })
      }
      if (pointindex == 2 || pointindex == 3 || pointindex == 6) {
        that.setData({
          muban: 2
        })
      }
      if (pointindex == 5 || pointindex == 8) {
        that.setData({
          muban: 3
        })
      }
    },
    //选择难度that.data.nandu 1是简单 2是中等 3是困难
    choose1() {
      var that = this;
      that.setData({
        num1: 1,
        dengji: 'LV1',
        life: 100,
        gongji: 20,
        fangyu: 20,
        nandu: 1
      })
      console.log(that.data.nandu)
  
    },
    choose2() {
      console.log('zhongdeng')
      var that = this;
      that.setData({
        num1: 2,
        dengji: 'LV2',
        life: 150,
        gongji: 30,
        fangyu: 30,
        nandu: 2
      })
    },
    choose3() {
      console.log('kunnan')
      var that = this;
      that.setData({
        num1: 3,
        dengji: 'LV3',
        life: 200,
        gongji: 40,
        fangyu: 40,
        nandu: 3
      })
    },
    //点击道具出现道具的作用
    daoju(){
      var that=this;
      if(that.data.zuoyong==false){
        that.setData({
          zuoyong:true
        })
      }else{
        that.setData({
          zuoyong:false
        })
      }
      
    },
  onReady: function () {

  },


  onShow: function () {

  },


  onHide: function () {

  },


  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})